In the communications field, various service function (SF) entities, a classifier, and a forwarder are deployed between a gateway general packet radio service (GPRS) support node (GGSN) and an external network.
As shown in FIG. 1, an uplink service packet sent from a GGSN to the Internet first passes through a classifier, and the classifier matches the service packet with a classification rule on the classifier. The service packet includes multiple packet characteristics, such as a source port number, a source Internet Protocol (IP), a destination port number, a destination IP, and a service type. The classification rule includes multiple entries. Each entry includes a matching condition, a service chain identifier (CID), a service index (SI), and a correspondence among a matching condition, a CID, and an SI. The matching condition includes all packet characteristics corresponding to the service packet, and target values respectively corresponding to all the packet characteristics. The matching condition is used to determine whether characteristic values of all the packet characteristics corresponding to the service packet respectively match target values corresponding to all the packet characteristics in the matching condition. The CID is used to identify a forwarding service chain. The SI is used to identify a quantity of SFs in the forwarding service chain corresponding to the CID. If all the packet characteristics corresponding to the service packet match a matching condition in an entry, the classifier encapsulates, into the service packet, a CID and an SI that are corresponding to the matching condition and that are in the entry, and sends, to a forwarder, the service packet into which the CID and the SI are encapsulated such that the forwarder forwards the service packet. The forwarder stores a forwarding rule, the forwarding rule includes identifier information of an SF, and the SF is the SF included in the service chain identified by the CID. The forwarder obtains, according to the CID carried in the service packet, a forwarding rule corresponding to the CID, and sends the service packet to the SF according to the identifier information that is of the SF and that is in the forwarding rule. For example, the forwarder sequentially sends the service packet to a function entity 1, a function entity 2, and a function entity 3 for processing, and then sends the service packet to an external network device.
In some approaches, if a packet characteristic corresponds to multiple target values, the packet characteristic needs to correspond to multiple matching conditions in a classification rule. Because each service packet belongs only to a specific service chain, each service packet can correspond only to one matching condition. When the packet characteristic corresponds to multiple target values, in order that all matching conditions are included, all permutations and combinations of possible target values need to be set in the classification rule. Consequently, entries of the classification rule and the forwarding rule drastically increase, and a large quantity of storage resources are occupied.